<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
<link rel="stylesheet" type="text/css" href="static/css/style.css" />
<script type="text/javascript" src="static/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="static/js/share.js"></script>
<title>简历</title>
</head>
<body>
	<div class="warp">
    	<div class="install_tip_top">
        	<div class="logo_ico"></div>
            <div class="logo"></div>
            <div class="info">中国首个工匠综合服务平台</div>
            <a class="intsll_btn" href="javascript:void(0)" onclick="share.download('http://image.qjbuluo.com/o_1da695eu21jg0j3310pbd5rtcua.apk', '')">免费安装</a>
        </div>
        <div class="userinfobox">
            <div class="loading"></div>
        </div>
        <div class="userblogbox">
            <div class="title1 pb20">
            	<h4>工作日志</h4>
                <span>视频工作日志只能实时拍摄，无法相册上传</span>
            </div>
            <div class="log_box">
                <div class="loading"></div>
            </div>
        </div>
        <div class="install_tip_buttom">
            <a href="#">安装巧匠部落APP，查看更多工友动态</a>
        </div>
        <div class="zw60"></div>
        <div class="botton_menubox1">
            <ul>
                <li class="share"></li>
                <li class="fav"></li>
            </ul>
            <a href="javascript:void(0)" class="chat">在线咨询</a>
            <a href="javascript:void(0)" class="tel"></a>
        </div>
    </div>
<script type="text/javascript">
var user_id = share.get_param('id');
function init_userinfo(data) {
    var html = '',
        occupations_init = function(list) {
            var html = '';
            if(list.length > 0) {
                $.each(list, function(index,value){
                    html += '<i>'+value.occupation+'</i> '
                })
            }
            return html;
        },
        credentials_init = function(list) {
            var html = '';
            if(list.length > 0) {
                $.each(list, function(index,value){
                    html += '\
                    <li>\
                        <div class="ico zs"></div>\
                        <div class="content">\
                            '+value.name+'\
                        </div>\
                    </li>\
                    ';
                })
            }
            return html;
        };
    html += '\
        <div class="resume_card">\
            <div class="card_box">\
                <div class="avatar" style="background-image:url('+ data.headUrl +')"></div>\
                <div class="username">\
                    <div>\
                        '+ data.nickname +'<i class="sfrz '+(data.authed ? '' : 'hide')+'"></i>\
                    </div>\
                </div>\
                <ul class="info2">\
                    <li>\
                        <div>\
                            <strong>'+share.fomat_num(data.extend.fanses).num+'</strong>\
                            <b>'+share.fomat_num(data.extend.fanses).unit+'</b>\
                        </div>\
                        <p>粉丝</p>\
                    </li>\
                    <li>\
                        <div>\
                            <strong>'+share.fomat_num(data.extend.follows).num+'</strong>\
                            <b>'+share.fomat_num(data.extend.follows).unit+'</b>\
                        </div>\
                        <p>关注</p>\
                    </li>\
                    <li>\
                        <div>\
                            <strong>'+share.fomat_num(data.extend.agrees).num+'</strong>\
                            <b>'+share.fomat_num(data.extend.agrees).unit+'</b>\
                        </div>\
                        <p>获赞</p>\
                    </li>\
                    <li>\
                        <div>\
                            <strong>'+share.fomat_num(data.extend.gifts).num+'</strong>\
                            <b>'+share.fomat_num(data.extend.gifts).unit+'</b>\
                        </div>\
                        <p>红包</p>\
                    </li>\
                    <li>\
                        <div>\
                            <strong>'+share.fomat_num(data.extend.rewards).num+'</strong>\
                            <b>'+share.fomat_num(data.extend.rewards).unit+'</b>\
                        </div>\
                        <p>打赏</p>\
                    </li>\
                </ul>\
            </div>\
            <ul class="menu">\
                <li class="active">\
                    <a href="javascript:void(0)">个人简历</a>\
                </li>\
                <li>\
                    <a href="javascript:void(0)">视频</a>\
                </li>\
                <li>\
                    <a href="javascript:void(0)">图片</a>\
                </li>\
                <li>\
                    <a href="javascript:void(0)">招工</a>\
                </li>\
            </ul>\
        </div>\
        <ul class="user_basic1">\
            <li>\
                <div class="ico gz"></div>\
                <div class="content">\
                    工种：\
                    '+occupations_init(data.occupations)+'\
                </div>\
            </li>\
            <li>\
                <div class="ico gl"></div>\
                <div class="content">\
                    工龄：'+(parseInt(data.seniority) > 0 ? data.seniority +'年' : '无')+'\
                </div>\
            </li>\
            <li>\
                <div class="ico nl"></div>\
                <div class="content">\
                    年龄：'+share.get_age(data.birthDay)+'岁\
                </div>\
            </li>\
            <li>\
                <div class="ico xb"></div>\
                <div class="content">\
                    性别：'+(share.get_sex(data.sex ))+'\
                </div>\
            </li>\
            <li>\
                <div class="ico dq"></div>\
                <div class="content">\
                    地区：'+(data.province ? data.province : '')+' '+(data.city ? data.city : '')+' '+(data.area ? data.area : '')+'\
                </div>\
            </li>\
            <li>\
                <div class="ico dh"></div>\
                <div class="content">\
                    电话：'+(typeof(data.telephone) != 'undefined' ? data.telephone : '')+'\
                </div>\
            </li>\
        </ul>\
        <div class="title1">\
            <h4>职业证书</h4>\
        </div>\
        <ul class="user_basic1">\
            '+credentials_init(data.credentials)+'\
        </ul>\
        <div class="title1">\
            <h4>个人简介</h4>\
        </div>\
        <div class="introduce">'+data.introduce+'</div>\
    ';
    $('.userinfobox').append(html);
    $('title').html(data.nickname+'的简历');
    userinfo_area_bind();
}
function get_userinfo(id) {
    $('.userinfobox .loading').show();
    var obj = {
        url: share.get_api_url()+'user/detail/' + id,
        success: function(data) {
            if(parseInt(data.status) != 0) {
                share.add_tip_a($('.userinfobox'), data.msg);
            } else if (parseInt(data.status) == 0) {
                share.remove_tip();
                init_userinfo(data.result)
            }
            
        },
        complete : function() {
            $('.userinfobox .loading').hide();
        }
    }
    share.ajax_control(obj);
}
function userinfo_area_bind() {
    $('.resume_card .menu li').on('click',function(){
        alert('下载APP查看更多信息.')
    })
    $('.resume_card .info3 li').on('click',function(){
        alert('下载APP使用此功能.')
    })
    $('.botton_menubox1').on('click', function(){
        alert('下载APP使用此功能.')
    })
}

//get log
function userinfo_logs_init(data) {
    var html = '',
        get_type_class = function(val) {
            let str = '';
            switch(parseInt(val)) {
                case 0:
                    str='text'
                    break;
                case 1:
                    str='img'
                    break;
                case 2:
                    str='video'
                    break;
            }
            return str
        },
        init_ivhtml = function(data) {
            if(parseInt(data.type) == 1) {
                var imghtml = '';
                var cls = 'c';
                switch(data.entries.length) {
                    case 1:
                        cls='a'
                        break;
                    case 2:
                        cls='b'
                        break;
                    case 4:
                        cls='b'
                        break;
                }
                $.each(data.entries, function(index, value) {
                    imghtml += '<li data-img="'+value.content+'" data-w="'+share.get_img_info(value.content).w+'" data-h="'+share.get_img_info(value.content).h+'"><div class="img" style="background-image:url('+value.content+')"></div></li>';
                });
                imghtml = '<ul class="img_l ' + cls + '">' + imghtml + '</ul>'
                return imghtml;
            }
            if(parseInt(data.type) == 2 || (data.videoUrl.length > 0 && data.cover.length > 0)) {
                var videohtml = '';
                videohtml = '\
                    <div class="video_box">\
                        <div>\
                            <img src="' + data.cover + '">\
                            '+(data.videoUrl.indexOf('?') > -1 ? '<p>'+share.get_video_info(data.videoUrl).time+'s   /  '+share.get_video_info(data.videoUrl).size+'</p>' : '' )+'\
                            <span class="dz">'+(data.agree > 0 ? data.agree : '')+'</span>\
                        </div>\
                    </div>\
                ';
                
                return videohtml;
            }
            return ''; 
        };
    $.each(data,function(index,value){
        html += '\
            <div data-id="'+value.id+'" class="log_list '+get_type_class(value.type)+'">\
                <div class="time_box">'+value.createTime+'</div>\
                <div class="content">\
                    '+value.summary+'\
                </div>\
                '+init_ivhtml(value)+'\
            </div>\
        ';
    });
    $('.log_box').append(html);
    userinfo_logs_bind();
}
function get_userinfo_logs(id) {
    $('.log_box .loading').show();
    var obj = {
        url: share.get_api_url()+'content/search',
        data: {
            userId: id,
            pageIndex: 0,
            pageSize: 10
        },
        success: function(data) {
            console.log(data);
            if(parseInt(data.status) != 0) {
                share.add_tip_a($('.log_box'), data.msg);
            } else if (parseInt(data.status) == 0) {
                share.remove_tip();
                if(data.result.list.length == 0) {
                    share.add_tip_a($('.log_box'), '工期太紧，TA还没有发过工作视频');
                } else {
                    userinfo_logs_init(data.result.list)
                }
                
            }
            $('.install_tip_buttom').show();
        },
        complete : function() {
            $('.log_box .loading').hide();
        }
    }
    share.ajax_control(obj);
}
function userinfo_logs_bind() {
    $('.log_box .video_box').on('click', function(){
        window.open('video.html?type=userprofile&id='+user_id+'&current_infoid='+$(this).closest('.log_list').attr('data-id'));
    });
    $('.img_l li').on('click', function(){
        show_large_img(this);
    })
}

$(function(){
    get_userinfo(user_id);
    get_userinfo_logs(user_id);
})
</script>
</body>
</html>
